function getUserInfo(){
    axios.get('/my/userinfo',{
        // headers:{
        //     Authorization:localStorage.getItem('token')
        // }
    }).then(({data}) => {
        // console.log(data);
      
        // console.log(data.data.user_pic);
        let name = data.data.nickname || data.data.username
        if(data.data.user_pic){
            $('.avatar').prop('src',data.data.user_pic).show()
        }else{
            $('.text-avatar-box').show()
            $('.text-avatar').html(name[0].toUpperCase())
        }
    
        $('#welcome').text('欢迎' + name)
    })
}
getUserInfo()
$('#btnLogout').on('click',function(){
    layer.confirm(
        '确认退出码?', 
        {icon: 3, title:'提示'},
         function(index){
        //do something
        //清楚token
        localStorage.removeItem('token')
        ///回到登陆页面
        location.href = '/login.html'
        layer.close(index);
      });
})